#pragma once

#include "IPrimitive.h"


class CPrimCone : public IPrimitive
{
private:
	float m_radius;
	float m_height;
	float m_angle;
	float m_tanAngle;
	float m_tanAnglePowerTwo;

public:
	CPrimCone(float m_radius, float height);
	~CPrimCone();
	

	bool intersect(const CRay& ray, float& dist, bool useGlobalCoordinates);
	void computeNormal(const CRay& ray, float dist, CVector3f& normal)const;
	bool isInside(const CVector3f& p)const;


private:
	bool isValideHeight(float h)const;
	float fmin(float f1, float f2)const;
	float calculateTTopEnd(const CRay& R)const;
};